package cn.ldf.keepaccounts.entity.pojo;

import java.io.Serializable;
import java.util.Date;

import cn.hutool.core.codec.Base64Encoder;
import cn.ldf.keepaccounts.entity.pojo.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;

/**
 * 用户文件表
 * @author ldf
 * @TableName user_file
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class UserFile extends BaseEntity {

    /**
     * 用户openId
     */
    private String openId;

    /**
     * 收款码
     */
    @JsonIgnore
    private byte[] paymentCode;
    /**
     * 收款码base64
     */
    @TableField(select = false,exist = false)
    private String paymentCodeBase64;
    /**
     * 文件类型
     */
    private String contentType;

    /**
     * 将头像转为base64返回
     * @return 结果集
     */
    public String getPaymentCodeBase64() {
        if (paymentCode != null){
            paymentCodeBase64 = Base64Encoder.encode(paymentCode);
        }
        return paymentCodeBase64;
    }

    public void setPaymentCodeBase64(String paymentCodeBase64) {
        this.paymentCodeBase64 = paymentCodeBase64;
    }
}